<template>
<onekit-page>
<onekit-view onekit-class="container">
	<div is="onekit-template-head" :DATA="`${JSON.stringify({title:'get/set/ScreenBrightness'})}`"></div>
	<onekit-view onekit-class="page-body">
		<onekit-view onekit-class="page-body-info">
			<onekit-view onekit-class="page-body-title">当前屏幕亮度</onekit-view>
			<onekit-text onekit-class="page-body-text-screen-brightness">{{screenBrightness}}</onekit-text>
		</onekit-view>
		<onekit-view onekit-class="page-section page-section-gap">
			<onekit-view onekit-class="page-section-title">设置屏幕亮度</onekit-view>
			<onekit-view onekit-class="body-view">
				<onekit-slider :value="screenBrightness" min="0" max="1" step="0.1" @Change="changeBrightness"></onekit-slider>
			</onekit-view>
		</onekit-view>
	</onekit-view>
	<div is="onekit-template-foot"></div>
</onekit-view>
</onekit-page></template>
<script>
/* eslint-disable */
import Vue from 'vue';
import onekit_template_0 from '../../../common/head.head.vue';Vue.component('onekit-template-head',onekit_template_0);
import onekit_template_1 from '../../../common/foot.foot.vue';Vue.component('onekit-template-foot',onekit_template_1);
const ONEKIT_JSON= {
  "navigationBarTitleText": "屏幕亮度",
  "usingComponents": {
    
  }
};
const ONEKIT_SJS = {
};
import wx from '../../../../weixin2vue/wx.js';
import Macro from '../../../../weixin2vue/Macro.js';
const {getApp,getCurrentPages} = Macro;
import Page from '../../../../weixin2vue/OnekitPage.js';
import Component from '../../../../weixin2vue/OnekitComponent.js';
export default Page(ONEKIT_JSON,["screenBrightness"],ONEKIT_SJS,{
    "onShareAppMessage"(){
      return {
        "title":'屏幕亮度',
        "path":'packageAPI/pages/screen-brightness/screen-brightness'
};
    },
    "data":{
        "screenBrightness":0
},
    "onLoad"(){
      this._updateScreenBrightness();
    },
    "changeBrightness"(e){
      const value = Number.parseFloat(e.detail.value.toFixed(1));
      this.setData({
        "screenBrightness":Number.parseFloat(e.detail.value.toFixed(1))
});
      wx.setScreenBrightness({
        value
});
    },
    "_updateScreenBrightness"(){
      wx.getScreenBrightness({
        "success":(res)=>{
          console.log(res);
          this.setData({
              "screenBrightness":Number.parseFloat(res.value.toFixed(1))
});
        },
        "fail"(err){
          console.error(err);
        }
});
    }
});

</script>
<style 
 lang="css">
.page-body-text-screen-brightness {
  font-size: 40px ;
  font-family: -apple-system-font, Helvetica Neue,Helvetica,sans-serif ;
}
.page-section-gap {
  padding: 15px ;
}
</style>